//(function($){
	
//	$(window).load(function(){
		
		var goodsId = localStorage.getItem("goodsId");
		var names = localStorage.getItem("name");
		var liang = 0;
		/////////////////////
		
		getCar(names,goodsId);
		
		////////////////////////
		$.ajax({
		   type: "get",
		   url: "http://datainfo.duapp.com/shopdata/getGoods.php",
		   data: "goodsID="+goodsId+"&pageCode=0",
		   dataType:"jsonp",
		   success:function(data){
//		     console.log(data[0])
		     var Imhtml = "";
		     var arr = eval(data[0].goodsBenUrl);
		     $.each(arr, function(index) {
		     	Imhtml+='<div class="swiper-slide content1">'
				Imhtml+='<img src="'+arr[index]+'">'
				Imhtml+='</div>'
				
		     });
		    $(".content").html(Imhtml);
//		    $(".banner").append('<div class="swiper-pagination lunbo"></div>');
		     
		     
		     
		     $(".shop_mess p").eq(0).html(data[0].goodsName);
		     $(".ph .price").html(data[0].price);
		     $(".buynumber").html(data[0].buynumber);
		   }
		});
		
	///////////////////////////点击返回	
	$(".fan").click(function(){
		window.open("shoplist.html","_self");
	})
	
	$(".click_ck").on("touchend",function(){
		window.open("xiangqing.html","_self");
	})
		
	////////////////////////添加到购物车
	var geshu=0;
	$(".car_num").css("display","none")
	$("#tj_car").on("touchend",function(){
		getCar(names,goodsId);
		
		geshu=parseInt(liang)
		geshu++;
		$.ajax({
		   type: "get",
		   url: "http://datainfo.duapp.com/shopdata/updatecar.php",
		   data: {userID:names,goodsID:goodsId,number:geshu},
		   dataType:"json",
		   success:function(data){
		     getCar(names,goodsId);
		   }
		});
		////////////////////购物车的展现
			
			
		
	})
	
	////////////////////数量
	function getCar(names,goodsId){
		var num=0;
		$.ajax({
			  type: "get",
			   url: "http://datainfo.duapp.com/shopdata/getCar.php",
			   data: {userID:names},
			   dataType:"jsonp",
			   success:function(data){
			   	$.each(data, function(index){
			     	num+=parseInt(data[index].number);
			     	if(goodsId==data[index].goodsID){
			     		liang = data[index].number;
			     	}
			   	})
			   	console.log(liang,num);
			   	if(num){
					$(".car_num").css("display","block").html(num);
				}else{
					$(".car_num").css("display","none")
				}
			   }
			});
		
	}
	
	
//	})
//})(jQuery)
